package entity

import (
	"shqsoft.cn/pasnj/base"

	"github.com/jinzhu/gorm"
)

//零售任务指标
type ConfIndiQhrw struct {
	ID   int    `gorm:"AUTO_INCREMENT;primary_key;column:ID"`
	RWMC string `gorm:"column:RWMC"` //任务名称
}

//TableName 零售任务指标
func (ConfIndiQhrw) TableName() string {
	return "T_CONF_INDI_QHRW"
}

//零售季度指标
type IndiTbJdzb struct {
	ID           int          `gorm:"AUTO_INCREMENT;primary_key;column:ID"`
	NF           int          `gorm:"column:NF"`   //年份
	LXID         int          `gorm:"column:LXID"` //类型ID
	ConfIndiQhrw ConfIndiQhrw `gorm:"ForeignKey:LXID"`
	J1           float64      `gorm:"column:J1"` //一季度
	J2           float64      `gorm:"column:J2"` //二季度
	J3           float64      `gorm:"column:J3"` //三季度
	J4           float64      `gorm:"column:J4"` //四季度
}

//TableName 零售季度指标
func (IndiTbJdzb) TableName() string {
	return "T_INDI_TB_JDZB"
}

//导入后执行分户处理
func IndiTbJdzbAfterImport(tx *gorm.DB, params map[string]string) (err error) {
	//	prams := make([]interface{}, 1)
	//	prams[0] = params["DRRQ"]
	//	tx.Exec("EXEC UP_BASE_JHCW_JJZB ?", prams...)
	return nil
}
func ConfIndiQhrwEF() base.EntityFunc {
	return func() interface{} {
		entity := ConfIndiQhrw{}
		return &entity
	}
}
func ConfIndiQhrwESF() base.EntitiesFunc {
	return func() interface{} {
		var entities []ConfIndiQhrw
		return &entities
	}
}
func IndiTbJdzbEF() base.EntityFunc {
	return func() interface{} {
		entity := IndiTbJdzb{}
		return &entity
	}
}
func IndiTbJdzbESF() base.EntitiesFunc {
	return func() interface{} {
		var entities []IndiTbJdzb
		return &entities
	}
}

func init() {
	relationship := []string{"ConfIndiQhrw"}
	base.DaoPoolObj.Put("ConfIndiQhrw", base.NewDefaultDao(ConfIndiQhrwEF(), ConfIndiQhrwESF(), nil))
	base.DaoPoolObj.Put("IndiTbJdzb", base.NewDefaultDao(IndiTbJdzbEF(), IndiTbJdzbESF(), relationship))
	base.SetAfterCallBack("IndiTbJdzb", IndiTbJdzbAfterImport)
}
